package ooday04;
//匿名内部类的练习---定时器(定时做任务)
import java.util.Timer;
import java.util.TimerTask;
public class TimerDemo {
    public static void main(String[] args) {
     /*   Timer timer=new Timer();
        int interval=1000;
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("111");
            }
        }, interval, interval);

      */
        Timer timer=new Timer();
        int interval=1000;
        timer.schedule(new TimerTask() {
            public void run() {
                System.out.println("222");
            }
        }, interval, interval);















     /*   Timer timer=new Timer();//定时器对象
        int interval=1000;//定时间隔（毫秒）
        timer.schedule(new TimerTask() {
            public void run() {//定时干的事---每1000毫秒执行一次
                System.out.println("该吃饭啦");
            }
        }, interval,3000);//定时计划表

      */

    }
}
